Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

directory-exists

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-exists

Check to see if a directory exists

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-40.69%
Maintainers
1
Weekly downloads
 
Created
Source

directory-exists Build Status

Check if a directory exists - synchronously or asynchronously

Install

$ npm install --save directory-exists

Usage:

directory should be a string of a relative or absolute path.

Asynchronous

With Callback:
const directoryExists = require('directory-exists');

directoryExists(directory, (error, result) => {
  console.log(result); // result is a boolean
});
With Promise:

If no callback function is supplied, directoryExists returns a promise.

const directoryExists = require('directory-exists');

directoryExists(directory).then(result => {
  console.log(result); // result is a boolean
});
Async/await:
const directoryExists = require('directory-exists');

(async function() {
  const result = await directoryExists(directory);
  console.log(result);  // result is a boolean
})();

Synchronous

const directoryExists = require('directory-exists');

directoryExists.sync(directory); // retuns a boolean

Why not use fs.exists?

Because asynchronous fs.exists is deprecated. Synchronous fs.existsSync is still fine to use, but this library does both sync and async.

License

MIT © timmydoza

Keywords

FAQs

Package last updated on 18 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc